/*
 * Copyright (C) 2023 Coder.AN
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */
#include "udp_img_trans.h"
#include <iostream>


int main(int argc, char* argv[])
{
    UDPImgReceiver img_receiver;

    if (argc != 2)
    {
        std::cout << "usage: demo_img_receiver <port>" << std::endl;
        return 0;
    }

    img_receiver.set_listen_port(atoi(argv[1]));

    if (!img_receiver.init())
    {
        std::cout << "Can not init img_receiver!" << std::endl;
        return 0;
    }

    while (true)
    {
        cv::Mat img = img_receiver.read();
        char title[128];
        sprintf(title, "localhost:%d", atoi(argv[1]));
        cv::imshow(title, img);
        if (cv::waitKey(5) == 27) break;
    }

    return 0;
}